package br.com.listadecompras.persistence;

import java.util.ArrayList;

import br.com.listadecompras.model.Group;
import br.com.listadecompras.model.Item;

import android.app.Activity;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;

public class Persistence extends Activity {
	
	public static final String ITENS_SEPARADOR = "|";
	public static final String NOME_DESCRICAO_ITEM_SEPARADOR = "$";
	
	public static final String GRUPOS_SEPARADOR = "#";
	
	public Persistence() throws Exception  {
		
		SQLiteDatabase sql = null;
		
		sql = this.openOrCreateDatabase("listaDeCompras.db", Context.MODE_PRIVATE, null);
		sql.close();		
	}
	
	/*public boolean insereItemArquivo(Item item) {
		
		try {
		
			FileOutputStream fos = this.openFileOutput("itens.txt", Context.MODE_APPEND);
			StringBuilder stringItem = new StringBuilder();
			
			OutputStreamWriter writer = new OutputStreamWriter(fos);
			PrintWriter pwriter = new PrintWriter(writer);
			
			stringItem.append(item.getNome()).append(Persistence.NOME_DESCRICAO_ITEM_SEPARADOR)
					  .append(item.getDescricao()).append(Persistence.ITENS_SEPARADOR);
			
			pwriter.println(stringItem.toString());
			pwriter.flush();
			pwriter.close();
			
			writer.close();
			
			fos.close();
			
			stringItem = null;
			
		} catch (Exception e) {
			return false;
		}
		
		return true;
	}*/
	
	public boolean insereGrupoArquivo(Group grupo){
		return true;
	}
	
	public ArrayList<Item> recuperaItensArquivo() {
		return null;
	}
	
	public ArrayList<Group> recuperaGrupoArquivo() {
		return null;
	}
}
